/*
	MIDAS Context Based Routing
	cbr_object.h
	Copyright (c) 2007 Radoslaw Olgierd Schoeneich
	MEAG IT PW
*/

#ifndef cbr_object_h_
#define cbr_object_h_

#include <map>
#include "cbr_debug.h"

#ifdef CBR_DEBUG

class cbr_Object;

class cbr_ObjectRegistry {
private:
	int next_ID;
	std::map<int, cbr_Object*> objects;

	static cbr_ObjectRegistry* inst;

public:
	cbr_ObjectRegistry() : next_ID(1)
	{
		if (inst == NULL)
			inst = this;
	}

	~cbr_ObjectRegistry()
	{
		cbr_ObjectRegistry::printDebug();
	}

private:
	int getID_(cbr_Object* obj);
	void freeID_(int ID);
	void printDebug_();

public:
	static int getID(cbr_Object* obj)
	{
		if (inst == NULL)
			inst = new cbr_ObjectRegistry();
		return inst->getID_(obj);
	}

	static void freeID(int ID)
	{
		if (inst == NULL)
			inst = new cbr_ObjectRegistry();
		inst->freeID_(ID);
	}

	static void printDebug()
	{
		if (inst == NULL)
			inst = new cbr_ObjectRegistry();
		inst->printDebug_();
	}
};

class cbr_Object {
private:
	int ID;

public:
	cbr_Object();
	cbr_Object(cbr_Object&);
	virtual ~cbr_Object();
};

#else	// CBR_DEBUG

class cbr_Object {
};

#endif	// CBR_DEBUG

#endif	// cbr_object_h_
